package bank.dao.impl;

import bank.dao.AccountDao;

import jakarta.annotation.Resource;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import bank.pojo.Account;


@Repository("accountDao")
public class AccountDaoImpl implements AccountDao {

    @Resource(name="jdbcTemplate")
    private JdbcTemplate jdbcTemplate;
    @Override
    public Account selectByActno(String actno) {
        String sql="select actno,balance from t_act where actno=?";
        Account account = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(Account.class), actno);
        return account;
         }

    @Override
    public int update(Account act) {
        String sql="update t_act set balance=? where actno=?";
        return jdbcTemplate.update(sql,act.getBalance(),act.getActno());
    }
}
